validate.js ➔ ... ➔ ???   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
import {isString, length} from '../string.utils.js';
2
import {_isNumber} from './number';
3
4
const validString = value => {
5
    if(!isString(value)){
6
        throw new Error('[strman] ' + value + ' is not a String.');
7
    }
8
9
    return true;
10
};
11
12
export {validString};
13
14
const validArrayString = array => {
15
16
    array.map((data) => {
17
        if(!isString(data)){
18
            throw new Error('[strman] ' + data + ' is not a String.');
19
        }
20
        return data;
21
    });
22
23
    return true;
24
};
25
26
export {validArrayString};
27
28
const validNumber = value => {
29
    if(!_isNumber(value)){
30
        throw new Error('[strman] ' + value + ' is not a Number.');
31
    }
32
33
    return true;
34
};
35
36
export {validNumber};
37
38
const validCharLength = char => {
39
    if(length(char) === 0){
40
        throw new Error('Char should be length >= 1');
41
    }
42
43
    return true;
44
};
45
46
export {validCharLength};
47